package com.hiwan.system.pojo;

import java.io.File;

import org.apache.commons.lang3.StringUtils;

import com.hiwan.system.common.persistence.BasePojo;

/**
 * 
 * Datetime ： 2013-9-12 下午2:51:56<br>
 * Title : FileInfo.java<br>
 * Description: 文件信息表 <br>
 * Copyright : Copyright (c) 2013<br>
 * Company : HW<br>
 * 
 * @author ZDM
 * 
 */
public class FileInfo extends BasePojo{
	/**
	 * 用户id
	 */
	private String userId;
	/**
	 * 文件编号（主键）
	 */
	private String fileId;
	/**
	 * 文件关联编号,与具体业务表关联
	 */
	private String attachId;
	/**
	 * 文件所属机构
	 */
	private String belongOrg;
	/**
	 * 文件名
	 */
	private String fileName;
	/**
	 * 文件长度
	 */
	private long fileLength;
	/**
	 * 文件宽度
	 */
	private long fileWidth;
	/**
	 * 上传时间
	 */
	private String uploadTime;

	/**
	 * 备注
	 */
	private String remark;
	/**
	 * 图片存储相对路径
	 */
	private String filePath;
	/**
	 * 缩略图存储相对路径
	 */
	private String tfilePath;
	
	/**
	 * 原文件名称
	 */
	private String originName;
	
	/**
	 * 文件顺序号
	 */
	private int fileOrder;
	

	/**
	 * 文件所属机构名称
	 */
	private String belongOrgName;
	
	
	public FileInfo() {
	}

	public FileInfo(String fileId, String attachId) {
		this.fileId = fileId;
		this.attachId = attachId;
	}

	public String getFileId() {
		return fileId;
	}

	public void setFileId(String fileId) {
		this.fileId = fileId;
	}

	public String getAttachId() {
		return attachId;
	}

	public void setAttachId(String attachId) {
		this.attachId = attachId;
	}

	public String getBelongOrg() {
		return belongOrg;
	}

	public void setBelongOrg(String belongOrg) {
		this.belongOrg = belongOrg;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getUploadTime() {
		return uploadTime;
	}

	public void setUploadTime(String uploadTime) {
		this.uploadTime = uploadTime;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark1(String remark) {
		this.remark = remark;
	}

	@Override
	public int hashCode() {
		return (this.attachId + this.belongOrg + this.fileName).hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof FileInfo) {
			FileInfo file = (FileInfo) obj;
			if (attachId != null && belongOrg != null && fileName != null
					&& attachId.equals(file.getAttachId())
					&& belongOrg.equals(file.getBelongOrg())
					&& fileName.equals(file.getFileName())) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String busiId) {
		this.filePath = (StringUtils.isBlank(busiId) ? "" : busiId + "/")
					+ (StringUtils.isBlank(this.belongOrg) ? "" : this.belongOrg + "/")
					+ this.fileName;

	}

	public String getTfilePath() {
		return tfilePath;
	}
	
	

	public long getFileLength() {
		return fileLength;
	}

	public void setFileLength(long fileLength) {
		this.fileLength = fileLength;
	}

	public long getFileWidth() {
		return fileWidth;
	}

	public void setFileWidth(long fileWidth) {
		this.fileWidth = fileWidth;
	}
	
	

	public int getFileOrder() {
		return fileOrder;
	}

	public void setFileOrder(int fileOrder) {
		this.fileOrder = fileOrder;
	}

	public void setTfilePath(String staticServerUrl) {
		int idx = this.fileName.lastIndexOf('.');
		this.tfilePath = staticServerUrl + "/" + this.belongOrg + "/"
				+ this.fileName.substring(0, idx) /*+ FileService.TFILE_SUFFIX*/
				+ this.fileName.substring(idx)+"?ver="+Math.random();
	}

	public String getOriginName() {
		return originName;
	}

	public void setOriginName(String originName) {
		this.originName = originName;
	}

	public String getBelongOrgName() {
		return belongOrgName;
	}

	public void setBelongOrgName(String belongOrgName) {
		this.belongOrgName = belongOrgName;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
	
}
